<template>
  <div class="mod-config">
    <el-dialog
      title="指标库"
      :visible.sync="dialogVisible"
      width="80%">
      <div class="avue-crud">
        <!--      定量添加-->
        <el-table :data="dataList" stripe tooltip-effect="light" ref="tableRef" @selection-change="handleSelectionChange"  v-if="tabType=='1'">
          <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
          <el-table-column prop="normLx" label="指标类型" min-width="150">
          </el-table-column>
          <el-table-column prop="normName" label="指标名称" min-width="150" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="normDw" label="指标单位" min-width="150">
          </el-table-column>
          <el-table-column prop="normSm" show-overflow-tooltip label="指标说明" min-width="300">
          </el-table-column>
          <el-table-column prop="normPx" label="指标序号" min-width="100">
          </el-table-column>
        </el-table>
        <!--      定性添加-->
        <el-table :data="dataList" stripe tooltip-effect="light" ref="tableRef" @selection-change="handleSelectionChange" v-if="tabType=='2'">
          <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
          <el-table-column prop="normLx" label="指标类型" min-width="150">
          </el-table-column>
          <el-table-column prop="normDw" label="数据提供部门" min-width="150">
          </el-table-column>
          <el-table-column prop="normPx" label="指标序号" min-width="100">
          </el-table-column>
        </el-table>
        <div class="avue-crud__pagination">
          <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
                         :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background
                         layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        
                    <el-button type="primary" @click="addZhibiao">添 加</el-button>
                    <el-button @click="dialogVisible = false">取 消</el-button>
                </span>
    </el-dialog>
  </div>
</template>
<script>
import {fetchList} from '@/api/hetongrenwu/zhibiaoTable'

export default {
  data() {
    return {
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      tabType:'1',
      selectedData:[],
      dialogVisible:false
    }
  },
  props: {
    hetongId: Number,
  },
  methods: {
    //初始化数据
    init(data){
      this.tabType=data.tabType;
      this.dialogVisible=data.dialogVisible;
      this.getDataList();
    },
    // 获取数据列表
    getDataList() {
      fetchList("htrw_zb").then(response => {
        this.dataList = response.data.data
      })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    handleSelectionChange(val){
      this.selectedData=val;
    },
    //添加选择的指标库
    addZhibiao(){
     //console.log(this.selectedData)
      this.dialogVisible=false
      this.$emit('selectedZhiBiao',this.selectedData)
    }
  }
}
</script>
